/*
* @author : TF-BJ-C064
* @creation : 2014-7-23 上午9:31:04
* @description : 
*
*/

package com.base;

import org.apache.log4j.Logger;
import org.hibernate.EmptyInterceptor;  

@SuppressWarnings("serial")  
public class HibermateInterceptor extends EmptyInterceptor {  
	
	private Logger log = Logger.getLogger(HibermateInterceptor.class);
  
    public String onPrepareStatement(String sql) {  
    	
    	if(sql == null)
    		return "";
    	String temp[] = sql.trim().split(" ");
    	if(temp!=null && temp.length>1){
    		String headerFlag = temp[0].trim(); 
    		if(!headerFlag.equals("select")){
    			//sql = "set autocommit=0;" + sql.trim() + "; set autocommit=1;";
    		}
    	}
    	log.info(""+sql);
    	
        return sql;  
    }  
  
}  